using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using BingleMaps.ViewModels;

namespace BingleMaps.Converters
{
	public class PushpinIconConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			foreach (var item in SettingsViewModel.AvailablePushpinIcons.Where(item => item.Value == (string)value))
				return item;
			return SettingsViewModel.DefaultPushpinIcon;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return ((KeyValuePair<string, string>)value).Value;
		}
	}
}